package cn.iocoder.yudao.module.enterprise;

import com.unfbx.chatgpt.OpenAiStreamClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.net.InetSocketAddress;
import java.net.Proxy;

/**
 * 项目的启动类
 *
 * @author StevenShen
 */
@SpringBootApplication
public class EnterpriseServerApplication {

    @Value("${chatgpt.apiKey}")
    private String apiKey;
    @Value("${chatgpt.apiHost}")
    private String apiHost;
    @Value("${chatgpt.hostname}")
    private String hostname;
    @Value("${chatgpt.port}")
    private Integer port;

    public static void main(String[] args) {
        SpringApplication.run(EnterpriseServerApplication.class, args);
    }

    @Bean
    public OpenAiStreamClient openAiStreamClient() {
        return OpenAiStreamClient.builder().apiHost(apiHost)
                .apiKey(apiKey)
                .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(hostname, port))).build();
    }

}
